<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title></title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="<%=path %>/js/jquery.js"></script>
	<script type="text/javascript">
		$(document).ready(function(){
			$("#submit").click(function(){
				$("#typeId").val();
				$("form").submit();
			});
			$("#update").click(function(){
				$("form").attr("action","<%=path %>/fileType/update.action");
				$("form").submit();
			});
			$(".toupdate").click(function(){
				var id = $(this).closest("tr").attr("id");
				$("#name").val($(this).closest("tr").find("td").eq(1).text());
				$("#typeId").val(id);
			});
			$(".delete").bind("click",function(){
				var id = $(this).closest("tr").attr("id");
				$("#typeId").val(id);
				$("form").attr("action","<%=path %>/fileType/delete.action");
				$("form").submit();
			});
		});
	
	</script>
	<style type="text/css">
		table {
			border:1px solid black;
			border-collapse:collapse; 
			margin-top:10px;
		}
		td,th {
			border:1px solid black;
		}
		a {
			margin:5px;
		}
	</style>
  </head>
  <body>
  <form action="<%=path %>/fileType/save.action" method="post">
  父类型:<select id="select" name="superAttachFileCategory.id"><c:forEach items="${list}" var="fileType"><option value="${fileType.id }">${fileType.name }</option></c:forEach></select> 名称:<input type="text" id="name" name="name"><a href="javascript:void(0);" id="submit">保存</a><a href="javascript:void(0);" id="update">更新</a>
  <input type="hidden" name="id" id="typeId">
  </form>
  	<table >
  		<tr>
  			<th>ID</th>
  			<th>类型名称</th>
  			<th>父类型</th>
  			<th>操作</th>
  		</tr>
  		<c:if test="${list!=null}">
  		 <c:forEach items="${list}" var="fileType">
    		<tr id="${fileType.id }">
    			<td>${fileType.id }</td>
    			<td>${fileType.name }</td>
    			<td>${fileType.superAttachFileCategory.name }</td>
    			<td><a href="javascript:void(0);" class="toupdate">修改</a><a href="javascript:void(0);" class="delete">删除</a></td>
  			</tr>
   		 </c:forEach>
  		</c:if>
  		
  	</table>
  </body>
</html>
